home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / LLIST.ZIP / DATASIZE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-26  |  4.2 KB  |  125 lines

  1. /* ------------------------------------------------------------------------------
  2. | FILE NAME: DataSize.h
  3. |
  4. | DOCUMENT: [1033.0]
  5. |
  6. | PURPOSE: To isolate and define compiler-dependent conventions so that source
  7. |          code can be objectively defined and easily ported.
  8. |
  9. | DESCRIPTION: 
  10. |
  11. |   The 8-bit 'Byte' is taken as the basic unit of storage.
  12. |    
  13. |   Edit the 'typedef' statements in this file so that they 
  14. |   are true of your compiler.
  15. |    
  16. |   To avoid ambiguity, use the types defined in this 
  17. |   file in place of the systematically ambiguous types:
  18. |   'int', 'short', 'long', 'void' etc.
  19. |
  20. | NOTE: 
  21. |
  22. | HISTORY:    11.08.93 by Lee Malone
  23. |----------------------------------------------------------------------------- */
  24.  
  25. #ifndef _DATASIZE_H_
  26. #define _DATASIZE_H_
  27.  
  28. /* 
  29. For 'Think C':---------------------------------------------------------------
  30.     
  31.    'Byte' is already defined by 'Think C' for the Pascal interface as 
  32.    being 1 byte long in 'struct' declarations, but is a 
  33.    'short' (2 bytes) when passed as an argument.  
  34.    
  35.    Use 'Byte' in structs or as local variables but DON'T pass a 'Byte'
  36.    as a parameter to another procedure: an error will result. Use the 'Pair'
  37.    type instead to pass byte-size data. 
  38.    
  39.    Also make sure all declarations are of the new form to 
  40.    avoid promotion conflicts. See p.206 "Think C 5.0 User manual".
  41.    
  42. For most other compilers:----------------------------------------------------   
  43. Move the following 2 lines outside of this comment block:
  44. typedef unsigned char  Byte;         
  45. typedef char           SignedByte; 
  46. */
  47. typedef unsigned char  Byte;         
  48. typedef char           SignedByte; 
  49.  
  50. typedef unsigned short   Pair;         /* 2 adjacent bytes */
  51. typedef unsigned long    Quad;         /* 4 adjacent bytes */
  52.  
  53. /* 
  54.    The 'int' type is ambiguous: it may be 2 or 4 bytes long.  
  55.    Use 'SignedPair' instead of 'int' if you want a 16-bit integer. 
  56.    Use 'SignedQuad' instead of 'int' if you want a 32-bit integer. 
  57.    See p.198 "Think C User manual". 
  58. */
  59.  
  60. typedef short       SignedPair; /* range: +/-        32,768 */
  61. typedef long        SignedQuad; /* range: +/- 2,147,483,647 */ 
  62.  
  63. typedef SignedByte  String;
  64.  
  65. /* For factual tests: */
  66. typedef SignedPair    Truth; /* 
  67.                               SignedPair used to avoid 
  68.                               alignment errors in structures and
  69.                               to allow 'Truth' values to be formed
  70.                               from arithmetic operations without
  71.                               casting. 
  72.                              */
  73. #define True        1
  74. #define False       0
  75.  
  76. /* Comparison values are interpreted as follows:
  77.  
  78.    Given two values, A and B, in which A is the left-most
  79.    parameter of a comparison procedure:
  80.    
  81.                   SomeComparisonProcedure(A,B);
  82.    
  83.    Comparison Value    Condition
  84.         0              if A = B.
  85.     positive number    if A > B.
  86.     negative number    if A < B.
  87.     
  88.     Comparison values are used for searching and sorting
  89.     procedures.
  90. */
  91. typedef SignedQuad    Comparison;
  92.  
  93. /* The 'void' type is ambiguous. Use the following instead: */
  94. #define Anything    void
  95. #define Nothing        void
  96.  
  97. typedef Anything    *AddressOfAnything;
  98. typedef Byte        *AddressOfByte;
  99. typedef Pair        *AddressOfPair;
  100. typedef Quad        *AddressOfQuad;
  101. typedef SignedByte  *AddressOfSignedByte;
  102. typedef SignedPair  *AddressOfSignedPair;
  103. typedef SignedQuad  *AddressOfSignedQuad;
  104. typedef String      *AddressOfString;
  105. typedef Truth       *AddressOfTruth;
  106.  
  107. typedef unsigned char  **AddressOfAddressOfByte;
  108. typedef String         **AddressOfAddressOfString;
  109.  
  110. typedef Anything    (*AddressOfAnyProcedure)();  
  111. typedef Byte        (*AddressOfByteProcedure)();
  112. typedef Comparison  (*AddressOfComparisonProcedure)();
  113. typedef Pair        (*AddressOfPairProcedure)();
  114. typedef Quad        (*AddressOfQuadProcedure)();
  115. typedef SignedPair  (*AddressOfSignedPairProcedure)();
  116. typedef SignedQuad  (*AddressOfSignedQuadProcedure)();
  117. typedef Truth       (*AddressOfTruthProcedure)();  
  118.  
  119. /* Define the procedures that manage dynamic memory. */
  120. #define FreeMemory(a)        free(a)
  121. #define AllocateMemory(a)    malloc(a)
  122.  
  123. #endif /* _DATASIZE_H_ */
  124.  
  125.